
import com.common.base.http.main.HttpManager.gson
import com.tencent.mmkv.MMKV

/**
 * Created by zsf on 2021/1/4 20:03
 * ******************************************
 * * 所有保存的数据统一处理
 * ******************************************
 */

val spUtils = MMKV.defaultMMKV()

fun <T> MMKV.put(key: String, articleData: T) {
    spUtils.encode(key, gson.toJson(articleData))
}

inline fun <reified T> MMKV.get(key: String): T? {
    val jsonString = spUtils.decodeString(key, "")
    try {
        return gson.fromJson(jsonString, T::class.java)
    } catch (e: Exception) {
        e.printStackTrace()
    }
    return null
}




